package ops.view.forms.component;

import javax.swing.JCheckBox;
import javax.swing.JComponent;

public class CheckboxInput extends FormInput {

	private JCheckBox checkBox;
	
	public CheckboxInput(String label) {
		super(label, true);
		
		checkBox = new JCheckBox();
	}
	
	@Override
	public Object getInputValue() {
		return checkBox.isSelected();
	}

	@Override
	public JComponent getInputComponent() {
		return checkBox;
	}

	@Override
	public void setInputValue(Object value) {
		if (!(value instanceof Boolean)) {
			checkBox.setSelected(false);
		} else {
			checkBox.setSelected((Boolean) value);
		}
	}

	@Override
	public void clearInput() {
		checkBox.setSelected(false);
	}

}
